<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/yuyue.css">
<!-- 引入 layui.css -->
<link rel="stylesheet" href="http://unpkg.com/layui@2.6.8/dist/css/layui.css">

<!-- 引入 layui.js -->
<script src="http://unpkg.com/layui@2.6.8/dist/layui.js"> </script>
</head>

<body>

    <div class="box">


        <div class="main">
            <button class="gg">返回主页</button>

            <div class="top">
                <select class="layui-form"></select>
            </div>
            <div class="center">
                <table>
                    <thead>
                        <tr>
                            <th>场次</th>
                            <th>状态</th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
            <div class="footer">
                <p>★ 一个手机号，一天只能预约一场。</p>
            </div>
        </div>
    </div>
</body>
<!-- JavaScript 日期处理类库 -->
<!-- http://momentjs.cn/ -->

<script src="./monent.js"></script>
<script src="./index.js"></script>
<script>
    let xiala = document.querySelector("select");
    let tbody = document.querySelector("tbody");
    let sure;
    // console.log(sessionStorage.getItem("token"));

    aFn(); 
    //监听下拉菜单的日期
    xiala.addEventListener("change", function (e) {
        tbody.innerHTML = "";
        //渲染当前日期的时间段
        af3(e.target.value)
    });

    //点击跳转到
    tbody.addEventListener("click", function (e) {
        let value = e.target.innerText;
        sessionStorage.setItem("day_time", e.target.getAttribute("data-day_time"));
        sessionStorage.setItem("show_id", e.target.getAttribute("data-show_id"));
        let dd = e.target.parentElement.firstElementChild.innerHTML;
        sessionStorage.setItem("dd", xiala.value +"  "+ dd);

        if (value === "可预约") {
            window.open("./yuyuecg.html",'_self')
        } else if (value === "已约满") {
            layer.alert('已经约满啦');
        }
    })


    async function aFn() {
        let t1 =await af1();
        let t2 = await af2(t1.result.token);
        //渲染今天的时间段
        af3(t2.result.list[0].day_time);
    }



    //判断预约时间

    let date = {
        isDuringDate: function (cc, beginDatestr, endDatestr) {
            var curDate = new Date().getTime(),
                beginDate = new Date( cc + " " + beginDatestr).getTime(),
                endDate = new Date( cc + " " + endDatestr).getTime();
            if ( beginDate >= curDate && endDate >= curDate) {
                return true;
            }
            return false;
        }
    }





</script>

</html>